package com.enterprise.struts2.feedback;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.enterprise.daoImpl.FeedbackDaoImpl;
import com.enterprise.domain.Feedback;
import com.enterprise.domain.News;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class FeedbackAction extends ActionSupport implements ModelDriven<Feedback> {

	/**
	 * 
	 */
	private Feedback feedback=new Feedback();
	
	
	
	public Feedback getFeedback() {
		return feedback;
	}
	public void setFeedback(Feedback feedback) {
		this.feedback = feedback;
	}
	FeedbackDaoImpl feedbackDaoImpl=new FeedbackDaoImpl();
	
	public String add(){
		if(feedback.getClassName().equals("-1")){
			feedbackDaoImpl.addFeedback(feedback);
				return "input2";
			
		}
		else if(feedback.getClassName().equals("1")){
			feedbackDaoImpl.addFeedback(feedback);
			return "success";
			
		}
		else {
			return "input"	;
		}
		
		
	}
	public String get(){
		if(feedbackDaoImpl.getFeedbackByClassName("-1")!=null)
			return "success";
		else {
			return "input"	;
		}
	}
	public String delete(){
		if(feedbackDaoImpl.deleteFeedback(feedback)>0)
			return "success";
		else {
			return "input"	;
		}
	}
	public String update(){
		System.out.println(feedback);
		if(feedbackDaoImpl.updateFeedback(feedback)>0)
			return "success";
		else {
			return "input"	;
		}
	
	}
	@Override
	public Feedback getModel() {
		// TODO Auto-generated method stub
		return feedback;
	}
	
	

}
